package com.tjtt.common.gps;

public class function {
	/// <summary>
    /// 由平面四参数进行二维转换
    /// </summary>
    /// <param name="_old"></param>
    /// <param name="Par"></param>
    /// <returns></returns>
    public xyh _2CoordTran_Cal_By_4s(xyh _old, Four_Par Par)
    {
        double cita = -Par.Cita/180.0* Math.PI;

        xyh re = new xyh();
        re.x = Par.dX + (_old.x * Math.cos(cita) + _old.y * Math.sin(cita)) * Par.k;
        re.y = Par.dY + (-_old.x * Math.sin(cita) + _old.y * Math.cos(cita)) * Par.k;
        re.h = _old.h;
        return re;
    }

    /// <summary>
    /// 由平面四参数进行二维转换
    /// </summary>
    /// <param name="_old"></param>
    /// <param name="Par"></param>
    /// <returns></returns>
    public xyh _2CoordTran_Cal_By_4s_fs(xyh _old, Four_Par Par)
    {
        double cita = Par.Cita / 180.0 * Math.PI;

        xyh re = new xyh();

        _old.x -= Par.dX;
        _old.y -= Par.dY;

        _old.x = _old.x / Par.k;
        _old.y = _old.y / Par.k;

        //原来旋转矩阵
        double a11 = Math.cos(cita); double a12 = Math.sin(cita);
        double a21 = -Math.sin(cita); double a22 = Math.cos(cita);


        double _A_ = a11 * a22 - a12 * a21;

        double b11 = a22; double b12 = -a21;
        double b21 = -a12; double b22 =a11;


        //求反的矩阵
        re.x = _old.x *b11  + _old.y * b12;
        re.y = _old.x * b21 + _old.y * b22;

        re.h = _old.h;
        return re;
    }
}
